import numpy as np
import matplotlib.pyplot as plt
from objectTable import ObjectTable

class Knapsack(ObjectTable):
    def __init__(self,table, W):
        super(Knapsack, self).__init__(table)
        self.W = W #cap of knapsack
        self.X = self.Xs()
    def Xs(self):
        self.X = [np.random.randint(0,2) for i in range(self.n)]
        return self.X
    def checkXs(self, Xs):
        if self.evalCosts(Xs) > self.W:
            return False
        else:
            return True


'''
table = np.loadtxt("table.csv", int)
W = 10
K = Knapsack(table, W)
#############test##################
print(K.table)
print(K.evalCosts([0,0,0,1,1]))
print(K.Xs())
X = K.Xs()
print(K.evalVals(X))
print(K.evalVals(K.Xs()))
###########end test################
'''

